package xyz.csmcool.imchat.feignclient;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import xyz.csmcool.imchat.config.FeignMultipartSupportConfig;
import xyz.csmcool.imutil.webVo.ResultVo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 什锦
 * @Package xyz.csmcool.imroom.feignclient
 * @since 2022/8/8 0:10
 */
@FeignClient(name="imoss",fallback = OssFileDegradeFeignClient.class,configuration= FeignMultipartSupportConfig.class)
@Component
public interface OssClint {

    /**
     * 上传聊天室文件
     * @param multipartFile
     * @return
     */
    @PostMapping(value = "/upload/room-file" ,consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    ResultVo<HashMap<String, String>>  uploadRoomFile(@RequestPart("file") MultipartFile multipartFile);

    /**
     * 上传聊天室图片文件
     * @param multipartFile
     * @return
     */
    @PostMapping(value = "/upload/room-files" ,consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public ResultVo<HashMap<String, List<String>>> uploadRoomFiles(@RequestPart("file") MultipartFile[] multipartFile);


    /**
     * 分片上传文件确认
     * @param fileName
     * @param uploadId
     * @return
     */
    @GetMapping("/upload/completeMultipartUpload")
    public ResultVo<HashMap<String,String>> completeMultipartUpload(@RequestParam("fileName") String fileName, @RequestParam("uploadId") String uploadId);
}
